import services from '@/apis/services'
import type { EmptyData, IList } from '@/apis/types'

import { baseUrl } from '../config'

import type {
  AccountListProps,
  BetRecord,
  BindingMailParams,
  CheckSmsParams,
  CheckTelParams,
  FindPwdParams,
  MemberInfo,
  ModifyFundPwdParams,
  ModifyLoginPwdParams,
  ModifyTelParams,
  TelephoneParams,
} from './types'
import type { TelNamespace } from './typing'

const baseName = baseUrl

// 获取会员信息
export const memberInfo = () => services.get<MemberInfo>(baseName + '/member/myInfo')

// 会员游戏钱包转出
export const withdraw = () => services.post<boolean>(baseUrl + '/withdraw')

// 绑定邮箱
export const updateEmail = (parmas: BindingMailParams) =>
  services.post<EmptyData, BindingMailParams>(baseName + '/member/updateEmail', {
    ...parmas,
  })
// 查询会员绑定的银行卡、电子钱包
export const queryPaymentAccountList = () =>
  services.get<AccountListProps[]>(baseName + '/member/queryPaymentAccountList')
// 查询会员VIP信息以及规则
export const queryVipInfo = () => services.post<any>(baseName + '/member/vip/queryVipInfo')
// 查询账变条件下拉列表
export const queryTransConditions = () =>
  services.post<any>(baseName + '/member/wallet/queryTransConditions')

export const queryTrans = (params: any) =>
  services.post<any[], any, IList>(baseName + '/member/wallet/queryTrans', params)

// 修改支付密码
export const updateWithdrawPassword = (parmas: ModifyFundPwdParams) =>
  services.post<EmptyData, ModifyFundPwdParams>(baseName + '/member/updateWithdrawPassword', {
    ...parmas,
  })
// 修改登录密码
export const updateLoginPassword = (parmas: ModifyLoginPwdParams) =>
  services.post<EmptyData, ModifyLoginPwdParams>(baseName + '/member/updateLoginPassword', {
    ...parmas,
  })
// 获取登录图片验证码
export const getLoginCaptchaCode = () => services.get<any>(baseName + '/member/login/captchaCode')
// 获取注册图片验证码
export const getRegisterCaptchaCode = () =>
  services.get<any>(baseName + '/member/register/captchaCode')

// ----------------------------------------------------------------------
// 获取验证码
export const sendSmsCode = (params: TelephoneParams) =>
  services.post<EmptyData, TelephoneParams>(baseName + '/sendSmsCode', { ...params })

// 校验验证码
export const checkSmsCode = (parmas: CheckSmsParams) =>
  services.post<EmptyData, CheckSmsParams>(baseName + '/checkSmsCode', { ...parmas })
// 找回密码
export const findPassword = (params: FindPwdParams) =>
  services.post<EmptyData, FindPwdParams>(baseName + '/findPassword', { ...params })

// 修改手机号-校验手机号
export const checkTelephone = (parmas: CheckTelParams) =>
  services.post<EmptyData, CheckTelParams>('/aggre/wap/member/checkTelephone', { ...parmas })

// 修改手机
export const modifyTelephone = (parmas: ModifyTelParams) =>
  services.post<EmptyData, ModifyTelParams>(baseName + '/modifyTelephone', { ...parmas })

// 注单列表
export const betRecord = (params: any) =>
  services.post<BetRecord[], any, IList>(baseName + '/gamebet/wap/queryGameBetList', {
    ...params,
  })

// 注单详情
export const betRecordData = (id: number) => services.get<BetRecord>(baseName + '/bet/' + id)
// 获取我的手机号码
export const getMyTelephone = () =>
  services.post<TelNamespace.AreaCode>(baseName + '/member/telephone/queryMyTelephone')
// 发送验证码
export const sendTelCode = (data: TelNamespace.AreaCode) =>
  services.post(baseName + '/member/telephone/sendCode', data)
// 校验验证码
export const verifyTelCode = (data: TelNamespace.VerifyCode) =>
  services.post(baseName + '/member/telephone/verifyCode', data)
